package com.finalx.TestPointerLocation;

import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;
import android.view.Display;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;

public class PointerLocationService extends Service {
	
	public static final String TAG = "PointerLocationService";

	public WindowManager mWm = null;
	public Display mDisplay = null;
	public testPointerLocationView mView = null;
	public LayoutParams mLayout = null;
	
	@Override
	public IBinder onBind(Intent arg0) {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
	public void onCreate() {
		// TODO Auto-generated method stub
		Log.d(TAG, "onCreate()");
		
		mWm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
		mDisplay = mWm.getDefaultDisplay();
		mView = new testPointerLocationView(getApplicationContext());
		mView.setVisibility(View.INVISIBLE);
		mLayout = new WindowManager.LayoutParams();
		
		mLayout.height = WindowManager.LayoutParams.MATCH_PARENT;
		mLayout.width = WindowManager.LayoutParams.MATCH_PARENT;
		mLayout.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
		mLayout.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
		
		mWm.addView(mView, mLayout);
		super.onCreate();
	}
	@Override
	public int onStartCommand(Intent intent, int flags, int startId) {
		// TODO Auto-generated method stub
		return START_STICKY;
	}

}
